package com.googlecode.afdbaccess.web.common.db.converters;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Map;

import com.googlecode.afdbaccess.cache.resultconversion.helpers.ResultSetConverterWithResult;
import com.googlecode.afdbaccess.cache.resultconversion.simpleconverters.SimpleMapsInListConverter;
import com.googlecode.afdbaccess.web.common.json.ExtJsJsonResponse;

public class SimpleExtJsJsonResponseConverter extends ResultSetConverterWithResult<ExtJsJsonResponse> {
    @Override
    public ExtJsJsonResponse convertResultSet(ResultSet resultSet) throws Exception {
        SimpleMapsInListConverter converter = new SimpleMapsInListConverter();
        
        ArrayList<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
        while(resultSet.next()) {
            Map<String, Object> returnedRow = converter.convertSingleRowToData(resultSet);
            result.add(returnedRow);
        }
        
        return new ExtJsJsonResponse(result);
    }
}